﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace CP.Utility
{
    public class GenericTypeHelper
    {
        public static Type GenGenericListType(string assemplyname, string gtype)
        {
            Assembly assembly = Assembly.Load(assemplyname);
            object gtypeobj = Activator.CreateInstance(assembly.GetType(gtype, true, true));
            return typeof(List<>).MakeGenericType(gtypeobj.GetType());
        }

        public static object GenGenericList(string assemplyname, string gtype)
        {
            Assembly assembly = Assembly.Load(assemplyname);
            object gtypeobj = Activator.CreateInstance(assembly.GetType(gtype, true, true));
            Type listType = typeof(List<>).MakeGenericType(gtypeobj.GetType());
            return Activator.CreateInstance(listType);
        }
    }
}
